package ccapp;

import java.util.Date;

import ccapp.util.CreditCardSystemConstants;


import frmsystem.*;


public class CardCreator extends Creator{	

	@Override
	public IEntry createTransaction(IParty party, IAccount account, int transactionType, double amount) {
		
		Entry entry = null;
				
		if (transactionType == CreditCardSystemConstants.TRANSACTION_CHARGE) {
			entry = new Charge(account);
			entry.setAmount(amount);
			entry.setDate(new Date());
			entry.setEvent(new PersonCharge());
			entry.setType(transactionType);
				
		} else if (transactionType == CreditCardSystemConstants.TRANSACTION_DIPOSIT) {
			entry = new Deposit(account);
			entry.setAmount(amount);
			entry.setDate(new Date());
			entry.setEvent(new PersonDeposit());
			entry.setType(transactionType);	
		}
		
		return entry;
	}
	
	@Override
	public IAccount createAccount(String accountNo, int accType) {
		
		if(accType == CreditCardSystemConstants.CREDITCARD_GOLD){
			Account account = new Gold();
			account.setAccountNo(accountNo);
			account.setInterestRate(CreditCardSystemConstants.GOLDCARD_MIN_INTEREST);
			account.setCurrentAmmount(0);
			return account;
		}
		if(accType == CreditCardSystemConstants.CREDITCARD_SILVER){
			Account account = new Silver();
			account.setAccountNo(accountNo);
			account.setInterestRate(CreditCardSystemConstants.SILVERCARD_MIN_INTEREST);
			account.setCurrentAmmount(0);
			return account;
		}
		if(accType == CreditCardSystemConstants.CREDITCARD_COPPER){
			Account account = new Copper();
			account.setAccountNo(accountNo);
			account.setInterestRate(CreditCardSystemConstants.COPPERCARD_MIN_INTEREST);
			account.setCurrentAmmount(0);
			return account;
		}
		return null;
	}
}
